

#include <iostream>
#include <list>
#include <vector>
#include <queue>
#include <stack>
#include <assert.h>
#include <string>
#include <algorithm>

using namespace std;

#include "reverse_iterator.h"
#include "vector.h"
#include "list.h"

void test_vector()
{
    my_vector::vector<int> v1(10, 1);
    v1.push_back(10);
    v1.push_back(11);
    v1.push_back(12);
    v1.push_back(13);
    v1.push_back(14);
    for (auto e : v1)
    {
        cout << e << ' ';
    }
    cout << endl;

    my_vector::vector<int>::iterator it = v1.begin();
    while (it != v1.end())
    {
        cout << *it << ' ';
        ++ it;
    }
    cout << endl;

    my_vector::vector<int> v2;
    v2.push_back(1);
    v2.push_back(2);
    v2.push_back(3);
    v2.push_back(4);
    v2.push_back(5);
    v2.push_back(6);
    for (auto e : v2)
    {
        cout << e << ' ';
    }
    cout << endl;

    v2 = v1;

    for (auto e : v2)
    {
        cout << e << ' ';
    }
    cout << endl;

    my_vector::vector<int> v3;
    v3.insert(v3.begin(), 1);
    v3.insert(v3.begin(), 2);
    v3.insert(v3.begin(), 3);
    v3.insert(v3.begin(), 4);
    v3.insert(v3.begin(), 5);
    v3.insert(v3.begin(), 6);

    for (auto e : v3)
    {
        cout << e << ' ';
    }
    cout << endl;

    my_vector::vector<int> v4(v1);
    for (auto e : v4)
    {
        cout << e << ' ';
    }
    cout << endl;

    v4.erase(v4.begin() + 3);
    v4.erase(v4.begin() + 3);
    v4.erase(v4.begin() + 3);
    v4.erase(v4.begin() + 3);
    v4.erase(v4.begin() + 3);

    for (auto e : v4)
    {
        cout << e << ' ';
    }
    cout << endl;
}

void test_list()
{
    my_list::list<int> l1(10, 5);
    for (auto e : l1)
    {
        cout << e << ' ';
    }
    cout << endl;

    l1.push_back(6);
    l1.push_back(7);
    l1.push_back(8);
    l1.push_back(9);
    l1.push_back(10);

    for (auto e : l1)
    {
        cout << e << ' ';
    }
    cout << endl;

    my_list::list<int> l2(l1);
    for (auto e : l2)
    {
        cout << e << ' ';
    }
    cout << endl;

    my_list::list<int> l3;
    l3.push_back(34);
    l3.pop_front();
    l3.push_front(156);
    l3.push_front(78);
    l3.pop_front();
    l3.push_front(99);
    l3.push_front(24);
    l3.push_front(1);
    l3.push_front(656);
    l3.push_front(66);
    l3.pop_back();
    l3.pop_back();
    l3.push_front(3434);
    l3.pop_front();
    l3.pop_front();
    l3.push_back(74);
    l3.pop_back();
    l3.push_front(4252);
    l3.push_back(876);
    l3.pop_front();
    l3.push_back(766);
    l3.pop_front();
    l3.pop_front();
    l3.push_front(565);
    l3.push_front(333);
    l3.pop_back();
    l3.pop_back();
    l3.push_front(222);
    l3.push_front(111);
    l3.pop_back();
    l3.pop_back();
    l3.pop_front();
    l3.push_front(555);
    l3.push_front(777);
    l3.push_front(666);
    l3.push_front(888);
    l3.push_back(999);
    l3.push_back(111111);
    l3.pop_front();
    l3.pop_front();
    l3.push_front(999);
    l3.push_front(777);
    l3.push_front(888);
    l3.pop_back();
    l3.pop_back();
    l3.push_back(888);

    for (auto e : l3)
    {
        cout << e << ' ';
    }
    cout << endl;

    l3 = l2;

    for (auto e : l3)
    {
        cout << e << ' ';
    }
    cout << endl;
}

void test()
{
    my_list::list<int> l1;
    l1.push_back(1);
    l1.push_back(2);
    l1.push_back(3);
    l1.push_back(4);
    l1.push_back(5);
    l1.push_back(6);
    for (auto e : l1)
    {
        cout << e << ' ';
    }
    cout << endl;

    my_list::list<int>::riterator it = l1.rbegin();
    while (it != l1.rend())
    {
        cout << *it << ' ';
        ++ it;
    }
    cout << endl;

    my_vector::vector<int> v1;
    v1.push_back(1);
    v1.push_back(2);
    v1.push_back(3);
    v1.push_back(4);
    v1.push_back(5);
    v1.push_back(6);
    for (auto e : v1)
    {
        cout << e << ' ';
    }
    cout << endl;

    my_vector::vector<int>::reverse_iterator it1 = v1.rbegin();
    while (it1 != v1.rend())
    {
        cout << *it1 << ' ';
        ++ it1;
    }
    cout << endl;
}

int main()
{
    //test_vector();

    //test_list();
    
    test();

    return 0;
}
